package creative.fire.interview.oracle;

public class ClassLoadTest {

	public static void main(String[] args) throws Exception {
		for (int repeat = 0; repeat < 3; ++repeat) {
			try {
				// "Real" name for X is outer class name+$+nested class name:
				Class<?> clazz = Class.forName("creative.fire.interview.oracle.ClassLoadTest");
				System.out.println(clazz.getClassLoader().toString());
			} catch (Throwable t) {
				System.out.println("load attempt #" + repeat + ":");
				t.printStackTrace(System.out);
			}
			ClassLoadTest.X x = new X();
			x.t();

			ClassLoadTest t = new ClassLoadTest();
			ClassLoadTest.Y y = t.new Y();
			y.t();
		}
	}

	class Y {
		void t() {
			System.out.println(s_count);
		}
	}

	private static class X {
		static {
			++s_count;
		}

		void t() {
			System.out.println(s_count);
		}
	} // End of nested class

	private static int s_count;

} // End of class